package com.mjk.common.tools.plumelog.service.controller.collect.impl;

import com.mjk.common.tools.logger.BizLogger;
import com.mjk.common.tools.plumelog.service.controller.collect.ILogCollect;
import com.plumelog.core.client.AbstractServerClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;

/**
 * 默认的日志收集，在不开其他组件的时候，默认使用的日志收集器
 *
 * 默认情况，只收集本机日志信息
 */
//@Configuration
//@ConditionalOnProperty(name = "spring.cloud.nacos.discovery.enabled", havingValue = "false", matchIfMissing = true)
public class DefaultLogCollectImpl implements ILogCollect {
    @Autowired
    private AbstractServerClient abstractServerClient;

    public DefaultLogCollectImpl(){
        System.out.println("DefaultLogCollectImpl");
    }
    public String collectLog(String indexStr, String queryStr,String from,String size){
        try {
            return abstractServerClient.get(indexStr, queryStr, from, size);
        }catch (Exception e){
            BizLogger.error(e);
            return "";
        }
    }
}
